<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
</head>
<style>
    .layui-layer-btn .layui-layer-btn1 {
        border-color: #FF5722;
        background-color: #FF5722;
        color: #fff;
    }
</style>
<body>
<div class="layui-fluid">
    <div class="layui-field-box">
        <div class="layui-card">
            <!--<div class="layui-form layui-card-header layuiadmin-card-header-auto">-->
                <!--<div class="layui-form-item">-->
                    <!--<input type="hidden" name="lid" value="{$lid}">-->
                    <!--<div class="layui-inline">-->
                        <!--<label class="layui-form-label">日期范围</label>-->
                        <!--<div class="layui-input-inline" style="width: 300px;">-->
                            <!--<input type="text" name="date" class="layui-input" id="test6" placeholder=" - " autocomplete="off">-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="layui-inline">-->
                        <!--<button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">-->
                            <!--<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>-->
                        <!--</button>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
            <div class="layui-card-body">
                <table id="demo" lay-filter="demo"></table>
            </div>
        </div>
    </div>
</div>
<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'laydate', 'table'], function(){
        var $ = layui.$,
                form = layui.form,
                table = layui.table,
                laydate = layui.laydate;

        laydate.render({
            elem: '#test6'
            ,range: true
            ,type: 'datetime'
        });

        //监听搜索
        form.on('submit(LAY-app-contlist-search)', function(data){
            var field = data.field;
            //执行重载
            table.reload('demo', {
                url: "/admin/Gift/ling/id/{$id}",
                where: field,
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

        //执行渲染
        table.render({
            elem: '#demo',
            url: "/admin/Gift/ling/id/{$id}",
            method: 'post',
            cols: [[
                {field: 'uid', title: '领取人'},
                {field: 'stage', title: '期数'},
                {field: 'time', title: '领取时间'}
            ]],
            page: {
                limits: [10, 20, 30, 40, 50]
            }
        });
    });

    //php时间戳用js转换为yyyy-mm-dd
    function formatDateTime(timeStamp) {
        var date = new Date();
        date.setTime(timeStamp * 1000);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        var second = date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute;
        second = second < 10 ? ('0' + second) : second;
        return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    }

    //补零
    function returnFloat(value){
        value = Math.round(parseFloat(value)*100)/100;
        var xsd = value.toString().split(".");
        if(xsd.length == 1){
            value = value.toString()+".00";
            return value;
        }
        if(xsd.length>1){
            if(xsd[1].length<2){
                value = value.toString()+"0";
            }
            return value;
        }
    }
</script>
</body>
</html>
